package com.mtons.core.entity.po;

import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.Digits;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.Type;
import org.hibernate.validator.constraints.NotEmpty;
import org.joda.time.LocalDate;
import org.springframework.format.annotation.DateTimeFormat;

@Entity
@Table(name="account")
public class AccountPO {

	@Id
	@Column(name="ID")
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Integer id;
	
	@NotNull(message="账号不能为空!")
	@Column(name="USERNAME", unique=true, nullable=false)
	private String username;
	
	@NotNull(message="密码不能为空!")
	@Column(name="PASSWORD", nullable=false)
	private String password;
	
	@NotNull
	@DateTimeFormat(pattern="dd/MM/yyyy")
	@Column(name="BIRTH", nullable=false)
	@Type(type="org.jadira.usertype.dateandtime.joda.PersistentLocalDate")
	private LocalDate birth;
	
	@NotNull
	@Digits(integer=8, fraction=2)
	@Column(name="SALARY", nullable=false)
	private BigDecimal salary;
	
	@NotEmpty
	@Column(name="SSN", nullable=false, unique=true)
	private String ssn;
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public LocalDate getBirth() {
		return birth;
	}
	public void setBirth(LocalDate birth) {
		this.birth = birth;
	}
	public BigDecimal getSalary() {
		return salary;
	}
	public void setSalary(BigDecimal salary) {
		this.salary = salary;
	}
	public String getSsn() {
		return ssn;
	}
	public void setSsn(String ssn) {
		this.ssn = ssn;
	}
	@Override
	public String toString() {
		return "AccountPO [id=" + id + ", username=" + username + ", password=" + password + ", birth=" + birth
				+ ", salary=" + salary + ", ssn=" + ssn + "]";
	}
}
